// [1, 2, [3, [4, 5, [6, [7, 8]]]]]
function flattern(array) {
  let result = [];
  for (let i = 0; i < array.length; i++) {
    const element = array[i];
    if(Array.isArray(element)) {
      result = result.concat(flattern(element));
    } else {
      result.push(element);
    }
  }
  return result;
}
console.log(flattern( [[1, 2, [30]], [3, [4, 5, [6, [7, 8]]]]]));